<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app"></div>

    <script src="../node_modules/@vue/reactivity/dist/reactivity/global.js"></script>

    <script>
        let { effect, reactive } = VueReactivity;
        let state = reactive({ name: 'zxd', age: 18, arr: [1, 2, 3]});
        effect(() => {
            console.log('render');
            // app.innerHTML = state.arr // 会获取长度
            // app.innerHTML = state.arr[2] + state.arr.length
            app.innerHTML = state.name + state.age
        })

        setTimeout(() => {
            // state.arr[100] = 1;
            state.name = 'zxx';
        }, 1000);

        // 重点：
        // 1.依赖收集：effect中的所有属性，都会收集effect， 方法是track
        // 2.触发更新：当这个属性值发生变化，会重新执行effect更新视图， 方法是trigger
    </script>
</body>
</html>